import requests from './request.js';

// 查询(自己的)日记列表
export const getDiaryListApi = (params) => requests({
    url: '/diary/getDiaryListApi',
    method: 'get',
    params: params,
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 查询(其他人的)日记列表
export const getOtherUserDiaryListApi = (params) => requests({
    url: '/diary/getOtherUserDiaryList',
    method: 'get',
    params: params,
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 根据日记aid后端获取日记相关的所有信息
export const getDiaryAllInfoByAid = (aid) => requests({
    url: `/diary/getDiaryAllInfoByAid?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 点击关注这个user
export const concernUser = (aid) => requests({
    url: `/diary/concernUser?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 取消关注这个user
export const cancelConcernUser = (aid) => requests({
    url: `/diary/cancelConcernUser?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 当前登陆用户给这条日记点赞
export const thumbsUpToDiary = (aid) => requests({
    url: `/diary/thumbsUpToDiary?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 当前登陆用户给这条日记取消点赞
export const cancelThumbsUpToDiary = (aid) => requests({
    url: `/diary/cancelThumbsUpToDiary?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 点击评论里面的赞，改变赞的状态
export const clickCommentLike = (aid) => requests({
    url: `/diary/clickCommentLike?aid=${aid}`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 发表评论
export const diaryCommentPublish = (params) => requests({
    url: `/diary/diaryCommentPublish`,
    method: 'post',
    data: params,
    headers: {
        token: localStorage.getItem('token'),
    }
});


// 获取系统给当前登陆的用户推荐的所有日记列表
export const getRecommentDiaryList = () => requests({
    url: `/diary/getRecommentDiaryList`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 获取当前登陆这个用户关注的所有用户的所有日记列表
export const getCurrentUserConcernUserDiaryList = () => requests({
    url: `/diary/getCurrentUserConcernUserDiaryList`,
    method: 'get',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 添加日记
export const addOrEditDiary = (params) => requests({
    url: `/diary/addOrEditDiary`,
    method: 'post',
    data: params,
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 在编辑日记的页面点击删除图标删除图片
export const deleteImage = (params) => requests({
    url: `/alioss/deleteImgByOss`,
    method: 'post',
    data: params,
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 当前登陆用户收藏这条日记
export const currentUserCollectCurrentDiary = (diaryAid) => requests({
    url: `/user-collect/currentUserCollectCurrentDiary?diaryAid=${diaryAid}`,
    method: 'post',
    headers: {
        token: localStorage.getItem('token'),
    }
});

// 当前登陆用户取消收藏这条日记
export const userCancelCollectDiary = (diaryAid) => requests({
    url: `/user-collect/userCancelCollectDiary?diaryAid=${diaryAid}`,
    method: 'post',
    headers: {
        token: localStorage.getItem('token'),
    }
});